/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header$
 * $Id$
 * $Author$
 * $Date$
 * $Revision$
 */
package com.elancom.framework.commons.util;

import java.io.File;

/**
 * @author elancom
 * @date 2012-8-2
 */
public class RenameComponentClassName {
	public static void main(String[] args) {
		String pathname = "D:\\Users\\elancom\\eclipse-jee-indigo-SR2-win32-x86_64\\platform-parent\\platform-component";
		// pathname = "E:\\temp\\java";
		File dir = new File(pathname);

		rename(dir);
	}

	public static void rename(File dir) {
		for (File file : dir.listFiles()) {
			if (file.isDirectory()) {
				rename(file);
			} else {
				if (file.getName().lastIndexOf("Compoent.java") != -1) {
					System.out.println(file.getAbsolutePath());
					String newFileName = file.getParent() + "\\" + file.getName().replace("Compoent.java", "Component.java");
					file.renameTo(new File(newFileName));
				} else if (file.getName().lastIndexOf("CompoentValidator.java") != -1) {
					System.out.println(file.getAbsolutePath());
					String newFileName = file.getParent() + "\\" + file.getName().replace("CompoentValidator.java", "ComponentValidator.java");
					file.renameTo(new File(newFileName));
				} else if (file.getName().lastIndexOf("CompoentTest.java") != -1) {
					System.out.println(file.getAbsolutePath());
					String newFileName = file.getParent() + "\\" + file.getName().replace("CompoentTest.java", "ComponentTest.java");
					file.renameTo(new File(newFileName));
				} else if (file.getName().lastIndexOf("-compoent.xml") != -1) {
					System.out.println(file.getAbsolutePath());
					String newFileName = file.getParent() + "\\" + file.getName().replace("-compoent.xml", "-component.xml");
					file.renameTo(new File(newFileName));
				}
			}
		}
	}
}
